// 默认传进来的是秒
function TimeObj(second, selector, timeOverCb) {
	var second = parseInt(second)
	var element = document.querySelector(selector)
	var timeOver = false
	var timeOverCb = timeOverCb
	var id = 0
	this.step = function() {
		second--
		if(!second) {
			clearInterval(id)
			timeOver = true
			timeOverCb()
			// return
		}
		element.innerText = timeFormat(second)
	}
	this.beginCount = function() {
		id = setInterval(this.step, 1000)
	}
	this.stopCount = function() {
		clearInterval(id)
	}
	function timeFormat(second) {
		if(!second) {
			return '00:00'
		}
		var min = Math.floor(second / 60)
		var sec = second % 60
		var minStr = min < 10? `0${min}` : min;
		var secStr = sec < 10? `0${sec}` : sec;
		return `${minStr}:${secStr}`
	}

}